#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<pthread.h>
#include<sys/types.h>
#include<unistd.h>

typedef struct Person
{
	char name[64];
	int age;
}Person;



//线程执行函数
void *mythread(void *arg)
{	
	//int n = *(int *)arg;
	Person * p = (Person *)arg;
	printf("child thread,pid==[%d],id==[%ld]\n",getpid(),pthread_self());
	//printf("n==[%d]\n",n);
	printf("age == [%d],name == [%s]\n",p->age,p->name);
}


//创建子线程
int main()
{
	Person p;
	memset(&p,0x00,sizeof( Person));
	strcpy(p.name,"Tom");
	p.age = 88;
	//int n = 99;
	pthread_t thread;
	int ret = pthread_create(&thread,NULL,mythread,&p);
	if(ret !=0)
	{
		printf("pthread_creat error,[%s]\n",strerror(ret));
		return -1;
	}
	printf("main thread,pid==[%d],id==[%ld]\n",getpid(),pthread_self());
	//为了让子线程能够执行起来
	sleep(1);
	return 0;
}
